package br.edu.unifei.mestrado.kl;

import br.edu.unifei.mestrado.commons.graph.GraphWrapper;
import br.edu.unifei.mestrado.commons.graph.NodeWrapper;
import br.edu.unifei.mestrado.commons.graph.RelationshipWrapper;
import br.edu.unifei.mestrado.commons.partition.AbstractPartition;
import br.edu.unifei.mestrado.commons.partition.AbstractPartitionIndex;
import br.edu.unifei.mestrado.mem.graph.Graph;
import br.edu.unifei.mestrado.mem.graph.PartitionIndexMem;
import br.edu.unifei.mestrado.mn.GraphViewMem;

public class KLMemory extends KL {

	protected GraphWrapper grafo = null;
	private AbstractPartitionIndex index = null;
	private GraphViewMem view = new GraphViewMem();

	public KLMemory(String graphFileName) {
		grafo = new Graph(GraphWrapper.NO_LEVEL, graphFileName);
		index = new PartitionIndexMem(AbstractPartition.TWO_WAY);
	}

	@Override
	public void readGraph() {
		grafo.readGraph();
	}

	@Override
	public RelationshipWrapper getArestaLinking(NodeWrapper va, NodeWrapper vb) {
		return grafo.getArestaLinking(va, vb);
	}

	@Override
	protected GraphWrapper getGrafo() {
		return grafo;
	}
	
	@Override
	public AbstractPartitionIndex getPartitionIndex() {
		return index;
	}
	
	@Override
	public void initView(GraphWrapper initialGraph) {
		view.initView(initialGraph);
	}

	@Override
	public void setShowView(boolean showView) {
		view.setShowView(showView);
	}

	@Override
	public void updateView(GraphWrapper grafo, int level, String it, int cutWeight) {
		view.updateView(grafo, level, it, cutWeight);
	}
	
	@Override
	public void updateViewCoarsed(GraphWrapper grafo, int level, String it, int cutWeight) {
		throw new RuntimeException("Esse método não deve ser chamado no KL");
	}
	
	@Override
	public void repaint() {
		view.repaint();
	}
}
